package flst.ipiweb.struts.action.promotion;

import ipiwebprocess.PromotionProcess;
import ipiwebtransverse.Promotion;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class PromotionSupprimerAction extends Action{

	private static PromotionProcess sPromotion = new PromotionProcess();

	public ActionForward execute(ActionMapping mapping, 
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response)
			throws Exception {

		String $retour = "";
		if ((request.getParameter("idPromotion") != null)) {
			// On supprime la promotion
			Promotion vPromotion = sPromotion.getPromotionById(new Integer(request.getParameter("idPromotion")).intValue());

			sPromotion.supprimerPromotion(vPromotion);
			
			$retour = "promotionSupprimer_ok";
			
			List<Promotion> listePromotion = sPromotion.listerPromotion();
 			
			request.setAttribute("listePromotion", listePromotion);
			
		} else {
			$retour = "promotion_ko";
		}

		return mapping.findForward($retour);
}
}
